'use strict';

module.exports =collectSameElements;
 function collectSameElements(collectionA, objectB) {
  let result=[];
  let arr1=[];
  let arr2=[];
  
  for(let i=0;i<collectionA.length;i++){
    for(let item in collectionA[i]){
      arr1.push(collectionA[i][item]);
      
    }
  }
arr2=objectB.value;

for(let item1 of arr1){
  for(let item2 of arr2){
    if(item1===item2){
      result.push(item1);
    }
  }
}
console.log(result);
return result;
}

collectSameElements([
  {key: 'a'}, {key: 'e'}, {key: 'h'}, {key: 't'}, {key: 'f'}, {key: 'c'}, {key: 'g'}, {key: 'b'}, {key: 'd'}
], {value: ['a', 'd', 'e', 'f']});